﻿using System.ComponentModel;
using System.Data;
using System.Windows; 
namespace WPFExcelReport
{
    public partial class TGB14 : ViewBase
    {
        #region ==dwKEY===========
        public static readonly DependencyProperty dwKEYProperty = DependencyProperty.Register("dwKEY",
            typeof(DataRowView), typeof(TGB14),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwKEYChanged));
        public DataRowView dwKEY
        {
            get
            {
                return (DataRowView)GetValue(dwKEYProperty);
            }
            set
            {
                SetValue(dwKEYProperty, value);
            }
        }
        private static void OndwKEYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TGB14;
            if (src != null)
            {
                src.dwKEY = (DataRowView)e.NewValue;
                src.Load();
            }
        }
        #endregion 
         
        
        public TGB14()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VICC_GABEW();
            IsMasterFromMV = true;
            InitializeComponent(); 
        }
        DataRowView LastdwKEY =null;
        public void Load()
        {
            if (LastdwKEY == dwKEY)
                return;
            dwKEY = dwKEY;
           
            string ART, VAR, FARBE, SPPART, ZWPART, FBPART, LO, LB, MDATE;
            ART = dwKEY["ART"].ToString();
            VAR = dwKEY["VAR"].ToString();
            FARBE = dwKEY["FARBE"].ToString();
            LO = dwKEY["LO"].ToString();
            LB = dwKEY["LB"].ToString();
            SPPART = dwKEY["SPPART"].ToString();
            ZWPART = dwKEY["ZWPART"].ToString();
            FBPART = dwKEY["FBPART"].ToString();
            MDATE = dwKEY["MDATE"].ToString();

            DataRow dwData =vm.SetData.Tables["ICC_QUERYTB"].NewRow();
            dwData["GPSPPART"] = SPPART;
            dwData["GPFBPART"] = FBPART;
            dwData["GPZWPART"] = ZWPART;
            dwData["MDATE"] = MDATE;
            DataSet SResult = ((VICC_GABEW)MV).QueryICC_GABEW(dwData, 3);
            MergeData(SResult,true);
        }

        private void DataGrid_Selected(object sender, RoutedEventArgs e)
        {

        }
    }
}
